from sanic import Sanic
from db_connect import ConnMysql
from db_connect import ConnRedis
from db_connect import ConnMysqlSlave


from api_product import bp_product

from api_product_a import bp_product_a


from api_intermediate import bp_intetmediate

from api_order import bp_apiorder


app = Sanic("App Name")

#配置项目静态文件夹地址
app.static('/static', './static')


app.blueprint(bp_product)

app.blueprint(bp_intetmediate)

app.blueprint(bp_product_a)

app.blueprint(bp_apiorder)

@app.listener('after_server_start')
async def notify_server_started(app, loop):
    ConnMysql(loop=loop)
    ConnRedis(loop=loop)
    ConnMysqlSlave(loop=loop)
    print('Server MySql and Redis successfully started!')


if __name__ == "__main__":

    app.run(port=8000, debug=True)